package com.by.course.config.web.jwt;

import io.jsonwebtoken.Claims;
import org.springframework.cache.annotation.Cacheable;

/**
 * <p>
 * JWT 服务类
 * </p>
 *
 * @author liujingeng
 * @since 2021/04/16
 */
public interface JwtService {

    /**
     * 获取token
     *
     * @param userId 用户id
     * @param openId 用户openId
     * @return java.lang.String
     * @author zhd
     * @date 2023/09/12 19:32
     */
    String getJwt(Long userId, String openId);

    /**
     * 验证token是否有效
     *
     * @param token token
     * @return io.jsonwebtoken.Claims
     * @author zhd
     * @date 2023/09/12 19:32
     */
    @Cacheable(cacheNames = "verifyToken", key = "'verifyJwt_' + #token", cacheManager = "caffeineCacheManager")
    Claims verifyJwt(String token);

    /**
     * token 是否过期
     *
     * @param token token
     * @return boolean
     * @author zhd
     * @date 2023/09/12 19:33
     */
    boolean isTokenExpired(String token);
}
